package com.woniuxy.service.impl;

import com.woniuxy.commons.exception.OrderLogException;
import com.woniuxy.commons.exception.code.OrderFoodExceptionCode;
import com.woniuxy.commons.utils.BeanCopyUtil;
import com.woniuxy.controller.form.OrderLogForm;
import com.woniuxy.dao.model.DietOrderLog;
import com.woniuxy.dao.DietOrderLogDao;
import com.woniuxy.service.DietOrderLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 订单日志表 服务实现类
 * </p>
 *
 * @author psy
 * @since 2022-06-28
 */
@Service
public class DietOrderLogServiceImpl extends ServiceImpl<DietOrderLogDao, DietOrderLog> implements DietOrderLogService {

    @Resource
    private DietOrderLogService dietOrderLogService;
    @Override
    public Boolean addOrderLog(OrderLogForm orderLogForm) {
        DietOrderLog dietOrderLog = BeanCopyUtil.copyOne(orderLogForm, DietOrderLog.class);
        boolean save = dietOrderLogService.save(dietOrderLog);
        if(save){
            return true;
        }else{
            throw new OrderLogException(OrderFoodExceptionCode.ORDERFOOD_ADD_FAIL.getCode(),OrderFoodExceptionCode.ORDERFOOD_ADD_FAIL.getMessage());
        }
    }
}
